package com.example.oms.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class RegistrationInfoVo {
    private Integer id;

    private Integer patientId;

    private Integer doctorId;

    private String status;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date appointmentDate;
    private String appointmentPeriod;

    private Integer isAppointmentRegistration;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date time;
    private String doctorName;
    private String image;
    private String deptName;
    // 自定义 JSON 输出格式
    @JsonProperty("appointmentPeriod")
    public String getFormattedAppointmentPeriod() {
        if (appointmentPeriod != null && appointmentPeriod.contains("~")) {
            String[] periods = appointmentPeriod.split("~");
            String startTime = periods[0].substring(0, 5); // 提取 "08:00"
            String endTime = periods[1].substring(0, 5);   // 提取 "08:30"
            return startTime + "~" + endTime;
        }
        return appointmentPeriod;
    }
    private double price;
    private String doctorRank;
}
